<template>
  <span></span>
</template>
<script>
  export default {
    props: ["dataSource"],
    data() {
      return {
        map: null
      }
    },
    created() {
      this.map = this.$store.state.maps.map;
    },
    mounted() {
      this.showLocation();
    },
    methods: {

      showLocation() {
        var points = this.dataSource;
        let geoc = new BMap.Geocoder()
        let point = new BMap.Point(points.lng, points.lat)
        geoc.getLocation(point, (rs) => {
          let addComp = rs.addressComponents
          let address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber
          var point = new BMap.Point(points.lng, points.lat);
          var label = new BMap.Label(address, {offset: new BMap.Size(20, -10)});
          var mark = new BMap.Marker(point);
          mark.setLabel(label);
          this.map.addOverlay(mark);
          this.map.setViewport([point]);
        })


      }
    }
  }
</script>
